package com.tianjin.weight.utils;

import com.tianjin.weight.mapper.*;
import org.springframework.beans.BeansException;
import org.springframework.stereotype.Component;

@Component
public class MapperBeanUtils {
    private static SysPermissionMapper sysPermissionMapper;
    private static SysRoleMapper sysRoleMapper;
    private static SysRolePermissionMapper sysRolePermissionMapper;
    private static SysUserMapper sysUserMapper;
    private static SysUserRoleMapper sysUserRoleMapper;
    private static SysUserWechatMapper sysUserWechatMapper;
    private static SysUserWechatRelationMapper sysUserWechatRelationMapper;
    private static SysLogMapper sysLogMapper;


    public static SysPermissionMapper getSysPermissionMapper(){ return getBean(SysPermissionMapper.class);}
    public static SysRoleMapper getSysRoleMapper(){ return getBean(SysRoleMapper.class);}
    public static SysRolePermissionMapper getSysRolePermissionMapper(){ return getBean(SysRolePermissionMapper.class);}
    public static SysUserMapper getSysUserMapper() throws BeansException{ return getBean(SysUserMapper.class);}
    public static SysUserRoleMapper getSysUserRoleMapper(){ return getBean(SysUserRoleMapper.class);}

    public static SysUserWechatMapper getSysUserWechatMapper(){ return getBean(SysUserWechatMapper.class);}
    public static SysUserWechatRelationMapper getSysUserWechatRelationMapper(){ return getBean(SysUserWechatRelationMapper.class);}

    public static SysLogMapper getSysLogMapper(){ return getBean(SysLogMapper.class);}

    public static Object getBean(String name){
        return BaseBeanUtils.getApplicationContext().getBean(name);
    }

    public static <T> T getBean(Class<T> clazz){
        return BaseBeanUtils.getApplicationContext().getBean(clazz);
    }


    public static <T> T getBean(String name,Class<T> clazz){
        return BaseBeanUtils.getApplicationContext().getBean(name,clazz);
    }


}
